import time
from threading import Thread
from multiprocessing import Process

def song(n):
    for i in range(n):
        print("song")
        time.sleep(0.5)


if __name__ == "__main__":
    start_time = time.time()
    song(5)
    end_time = time.time()
    print(f"正常执行时间为:{end_time - start_time}秒")


#创建多线程
for i in range(5):
    start_time = time.time()
    t = Thread(target=song(5))
    # t = Process(target=song)
    t.start()
    end_time = time.time()
    print(f"多线程执行时间为:{end_time-start_time}秒")

#创建多进程
for i in range(5):
    start_time = time.time()
    t = Process(target=song(5))
    t.start()
    end_time = time.time()
    print(f"多进程执行时间为:{end_time-start_time}秒")